package com.pro.springbootpro.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;

/**
 * 业务：在注册用户后发送邮件，短信
 */
@Service
public class UserRegistryService implements ApplicationEventPublisherAware {

    private ApplicationEventPublisher applicationEventPublisher;


    public void registry(String userName){
        System.out.println("用户【"+userName+"】注册成功");
        applicationEventPublisher.publishEvent(new MyEvent(this));
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher = applicationEventPublisher;
    }
}